import request from '@/utils/request';

export function getAddresses(userId) {
    return request({
        url: '/user/address',
        method: 'get',
        params: { userId }
    });
}

export function addAddress(address) {
    return request({
        url: '/user/address',
        method: 'post',
        data: address
    });
}

export function updateAddress(address) {
    return request({
        url: '/user/address',
        method: 'put',
        data: address
    });
}

export function deleteAddress(userId, shippingId) {
    return request({
        url: `/user/address/${shippingId}`,
        method: 'delete',
        params: { userId }
    });
}

export function setDefaultAddress(userId, shippingId) {
    return request({
        url: `/user/address/${shippingId}/default`,
        method: 'put',
        params: { userId }
    });
}